package cn.easybuy.web.backend;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import cn.easybuy.entity.User;
import cn.easybuy.service.UserService;
import cn.easybuy.service.impl.UserServiceImpl;
import cn.easybuy.util.Page;

public class MemberUserServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String opr=request.getParameter("opr");
		String currNo=request.getParameter("currNo");
		if (currNo==null||currNo=="") {
			currNo="1";
		}
		PrintWriter out =response.getWriter();
		UserService uService = new UserServiceImpl();
		Page page=new Page();
		page.setPageSize(5);
		int totalCount =uService.getTotalCount();
		page.setTotalCount(totalCount);
		page.setCurrentPageNumber(Integer.parseInt(currNo));
		List<User> userList =uService.getPageUsersList(page.getCurrentPageNumber(), page.getPageSize());
		page.setUserList(userList);
		
		String userJson=JSON.toJSONString(page);
		out.print(userJson);
		out.flush();
		out.close();
		
	
		
	}

}
